package com.qdsg.ysg.doctor.ui.adapter.tree.provider;

import android.widget.CheckBox;

import com.chad.library.adapter.base.entity.node.BaseNode;
import com.chad.library.adapter.base.provider.BaseNodeProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.qdsg.ysg.doctor.R;
import com.qdsg.ysg.doctor.entity.LeafNode;

import org.jetbrains.annotations.NotNull;

/**
 * @Description: java类作用描述
 * @Author: lzp
 * @CreateDate: 2023/12/20 14:26
 * @UpdateRemark: 更新说明
 */
public class ThirdProvider extends BaseNodeProvider {

    @Override
    public int getItemViewType() {
        return 3;
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_tree_third;
    }

    @Override
    public void convert(@NotNull BaseViewHolder helper, @NotNull BaseNode data) {
        LeafNode entity = (LeafNode) data;
        CheckBox checkBox = helper.getView(R.id.checkbox);
        checkBox.setText(entity.getTitle());
        checkBox.setChecked(entity.isChecked);
        checkBox.setOnClickListener(v -> {
            entity.isChecked = !entity.isChecked;
            checkBox.setChecked(entity.isChecked);
        });
//        ((CheckBox) helper.getView(R.id.checkbox)).setOnCheckedChangeListener((buttonView, isChecked) -> entity.isChecked = isChecked);
    }
}